package com.gmail.bloim.serg.testrunner;

import java.util.ArrayList;

/**
 * User: Администратор
 * Date: 26.04.13
 * Time: 14:34
 */
public class TestResultHandlerObserver implements TestResultHandler {
    private ArrayList<TestResultHandler> handlers = new ArrayList<TestResultHandler>();

    public void add(TestResultHandler resultHandler) {
        handlers.add(resultHandler);
    }

    @Override
    public void onTestSuccess(Test test) {
        for (TestResultHandler handler : handlers) {
            handler.onTestSuccess(test);
        }
    }

    @Override
    public void onTestFail(Test test) {
        for (TestResultHandler handler : handlers) {
            handler.onTestFail(test);
        }
    }

    @Override
    public void onTestException(Test test, Throwable e) {
        for (TestResultHandler handler : handlers) {
            handler.onTestException(test, e);
        }
    }

    @Override
    public void onTestStart(Test test) {
        for (TestResultHandler handler : handlers) {
            handler.onTestStart(test);
        }
    }

    @Override
    public void onTestFinish(Test test) {
        for (TestResultHandler handler : handlers) {
            handler.onTestFinish(test);
        }
    }
}
